<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="css/style.css" />
		<link rel="stylesheet" href="css/mui.picker.min.css" />
		<style>
			.ctn{
				padding-bottom: 0 !important;
				background-color: #1D1D1D;
			}
			.mui-bar-nav {
			    top: 0;
			    -webkit-box-shadow: 0 1px 6px #1D1D1D;
			     box-shadow: 0 1px 6px #1D1D1D; 
			}
		</style>
	</head>
	<body class="optionalPage ctn">
		<!--navBar-->
		<header class="mui-bar mui-bar-nav">
			<span class="mui-action-back mui-icon mui-icon-arrowleft"></span>
			<h1 class="mui-title">历史委托</h1>
		</header>
		<!--contInner-->
		<div class="contInner history_title">
			<div class=" mui-content part ctn">
				<div class="mui-row have_totol title_span">
					<ul>
						<li id="start" data-options='{"type":"date"}' class="mui-col-sm-4 mui-col-xs-4 ">
							<span>起始日期</span><br />
							<span id="time" ></span>
						</li>
						<li class="mui-col-sm-4 mui-col-xs-4">
							<img src="images/turns.png" alt="" style="width:0.8rem;height: 0.8rem;margin-top: 0.3rem;"/>
						</li>
						<li id="end" data-options='{"type":"date","beginYear":year,"beginMonth":month,"beginDay":day}' class="mui-col-sm-4 mui-col-xs-4">
							<span>截止日期</span><br />
							<span id="times"></span>
						</li>
					</ul>
				</div>
				<ul class="order_title">
					<li class="mui-col-sm-4 mui-col-xs-4 deal_name">
						<span>名称</span>
					</li>
					<li class="mui-col-sm-2 mui-col-xs-2">
						<span>成本/订单</span>
					</li>
					<li class="mui-col-sm-2 mui-col-xs-2">
						<span>委托方/方向</span>
					</li>
					<li class="mui-col-sm-4 mui-col-xs-4">
						<span>状态/时间</span>
					</li>
				</ul>
				<div class="mui-row" id="day_lists">
	
				</div>
			</div>
		</div>

	</body>
	<script src="js/mui.min.js"></script>
	<script src="js/mui.picker.all.js"></script>
	<script src='libs/easymob-webim-sdk/jquery-1.11.1.js'></script>
	<script >jQuery.noConflict()</script>
	<script src='js/mstock.js'></script>
	<script src='js/configs.js'></script>
	<script src='json/all.js'></script>
	<script type="text/javascript">
		mui.init();
		var year=new Date().getFullYear() ;
		var  month=new Date().getMonth()+1;
		var day=new Date().getDate();
		var days=day-7<=0?(30-7+day):(day-7);
		var time=year+'-'+month+'-'+days;//起始时间
		var times=year+'-'+month+'-'+day;//结束时间
		if(day<7){
			time=year+'-'+(month-1)+'-'+days;//起始时间
		}
		document.getElementById("time").innerHTML=time;
		document.getElementById("times").innerHTML=times;
		/*var year=new Date().getFullYear() ;
		var  month=new Date().getMonth()+1;
		var days=new Date().getDate()-7;
		var day=new Date().getDate();
		var time=year+'-'+month+'-'+day;*/
		var _data = {
             	account:account,
             	entrust1:times,
             	entrust2:time
            }
		dataRequest(_data)
			function dataRequest(_data){
				jQuery("#day_lists").empty();
				jQuery.ajax({
					type:'post',
					url:server.stockDay,
					data:_data,
					success:function(data){
		                console.log(data);
		             	for(i=0;i<data.data.length;i++){
		             		var stockCode=data.data[i].stockCode;
			                var stockName=data.data[i].stockName;
			             	var price=data.data[i].price;
			             	var count=data.data[i].count;
			                var billStatus=data.data[i].billStatus;
			                var dealTime=data.data[i].createTime||'未知';
			                var _billStatus,_tradeType,_priceType,_src;
			                switch(billStatus){
			                	case 1:
			                		_billStatus = '已接收';break;
			                	case 2:
			                		_billStatus = '待成交';break;
			                	case 3:
			                		_billStatus = '已撤单';break;
			                	case 4:
			                		_billStatus = '已成交';break;
			                	case 5:
			                		_billStatus = '已作废';break;
			                	default:
			                		_billStatus = '未知';break;
			                }
			                switch(data.data[i].tradingType){
			                	case 0:
			                		_tradeType = '买';break;
			                	case 1:
			                		_tradeType = '卖';break;
			                	default:
			                		_tradeType = '未知';break;
			                }
			                switch(data.data[i].billType){
			                	case 0:
			                		_priceType = '市价';break;
			                	case 1:
			                		_priceType = '限价';break;
			                	default:
			                		_priceType = '未知';break;
			                }
			                switch(data.data[i].currency){
			                	case 1:
			                		_src = 'images/HK_20x15_@3x.png';break;
			                	case 2:
			                		_src = 'images/US_40_29.png';break;
			                	default:
			                		_src = '';break;
			                }
			              jQuery("#day_lists").append("<ul class='deal_logo' style='margin-bottom: 10px;;'><li class='mui-col-sm-4 mui-col-xs-4'style='text-align: left;'><img style='height:15px;margin-top: 3px;' src='"+_src+"' alt='' class='mui-pull-left'><span class='stockName'>"+stockName+"</span><br><span style='margin-left:20px;color:#515252;'>"+stockCode+"</span></li><li class='mui-col-sm-2 mui-col-xs-2' style='text-align: center;'><span>"+price+"</span><br><span style='font-size: 14px;color:#515252;'>"+_priceType+"<span></li><li style='text-align: center' class='mui-col-sm-2 mui-col-xs-2' style='text-align: center;'><span style='color:#DAAC32'>"+count+"</span><br><span style='font-size: 14px;color:#515252;'>"+_tradeType+"<span></li><li class='mui-col-sm-4 mui-col-xs-4 deal_logo4'><span>"+_billStatus+"</span><br><span>"+dealTime+"</span></li></ul>");
		             	}
		           },
		           error:function(result){
		           		console.log(result);
		           }
					
				})
			}  
		var dtpicker = new mui.DtPicker({
		    type: "date",//设置日历初始视图模式 
		}) 
		var dtpicker = new mui.DtPicker({
		    "type": "date",
		    "value": time
		})
		var dtpickers = new mui.DtPicker({
		    "type": "date",
		    "value": times
		})
		document.querySelector('#start').addEventListener('tap',function () {
		   	dtpicker.show(function(ev) {
		   		var ts=document.getElementById("times").innerHTML;//ending time
		    	if(ev>ts){
		    		document.getElementById("time").innerHTML=ts;
		    	}else{
		    		 document.getElementById("time").innerHTML=ev;
		    	}
		    	var timS=document.getElementById("time").innerHTML;
			   	_data['dealDate1'] = timS;
		    	_data['dealDate2'] = ts;
		    	dataRequest(_data);
		   	})
		})
		document.querySelector('#end').addEventListener('tap',function () {
		    dtpickers.show(function(e) { 
		    	var t=document.getElementById("time").innerHTML;//starting time
		    	if(e<t){
		    		document.getElementById("times").innerHTML=t;
		    	}else{
		    		 document.getElementById("times").innerHTML=e;	
		    	}
		    	var timE=document.getElementById("times").innerHTML;
			    _data['dealDate1'] = t;
		    	_data['dealDate2'] = timE;
		    	dataRequest(_data);
		    }) 
		})
		
	</script>
</html>